package day10;

public class Homework {
    public static void main(String[] args) {

    }

    public static void demo1() {
        Thread t1 = new Thread(new Demo1(1,null),"线程1");
        Thread t2 = new Thread(new Demo1(2,t1),"线程2");
        Thread t3 = new Thread(new Demo1(3,t2),"线程3");
        t1.start();
        t2.start();
        t3.start();
    }
}

class Demo1 implements Runnable {
    int n;
    Thread t;

    public Demo1(int n, Thread t) {
        this.n = n;
        this.t = t;
    }

    @Override
    public void run() {
        if (t!=null){
            try {
                t.join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        String name = Thread.currentThread().getName();
        for (int i = 1; i < 100; i++) {
            if (i % n == 0) {
                System.out.println(name + "求出的" + n + "倍数");
            }
        }
    }
}